#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include common_scripts\utility;

drawLabel(text, location_X, location_Y, margin_X, margin_Y, font, fontSize, alpha, destroyOnDeath)
{
	label = self createFontString(font, fontSize);
	label setPoint(location_X, location_Y, margin_X, margin_Y);
	label setText(text);
	label.alpha = alpha;

	if (destroyOnDeath)
	{
		disposeOnDeath(label);
	}
}

drawPlayersAlive()
{
	self endon("death");
	self endon("disconnect");
	
	label = self createFontString("default", 1.4);
	label2 = self createFontString("default", 1.4);
	alive1 = self createFontString("default", 1.4);
	alive2 = self createFontString("default", 1.4);
	label setPoint("TOPLEFT", "TOPLEFT", 12, 120);
	label2 setPoint("TOPLEFT", "TOPLEFT", 12, 130);
	alive1 setPoint("TOPLEFT", "TOPLEFT", 94, 120);
	alive2 setPoint("TOPLEFT", "TOPLEFT", 94, 130);
	label.hidewheninmenu = true;
	label2.hidewheninmenu = true;
	alive1.hidewheninmenu = true;
	alive2.hidewheninmenu = true;
	self thread disposeOnDeath(label);
	self thread disposeOnDeath(label2);
	self thread disposeOnDeath(alive1);
	self thread disposeOnDeath(alive2);
	//self thread doAlpha(label);
	//self thread doAlpha(label2);
	//self thread doAlpha(alive1);
	//self thread doAlpha(alive2);
	
	for(;;)
	{
		if (getDvar("g_gametype") != "dm")
		{
		
			if (self.pers["team"] == "axis")
			{
				label setText("^2Allies alive:");
				label2 setText("^1Enemies alive:");
				alive1 setText(GetTeamPlayersAlive("axis"));
				alive2 setText(GetTeamPlayersAlive("allies"));
			}
			else
			{
				label setText("^2Allies alive:");
				label2 setText("^1Enemies alive:");
				alive1 setText(GetTeamPlayersAlive("allies"));
				alive2 setText(GetTeamPlayersAlive("axis"));
			}
		} 
		else
		{
			
			enemyPlayersAlive = -1;
			
			for( i = 0 ; i < level.players.size ; i++ )
			{
				if (isAlive(level.players[i]))
					enemyPlayersAlive += 1;
			}
			
			label setText("^2Allies alive:");
			label2 setText("^1Enemies alive:");
			alive1 setText("1");
			alive2 setText( enemyPlayersAlive );
			
		}
		wait(0.1);
	}
}

disposeOnDeath(element)
{
	self waittill("death");
	element destroy();
}

/*
doAlpha(element)
{
	element.alpha = 0;
	level waittill("prematch_over");
	element.alpha = 0.1;
	wait 0.01;
	element.alpha = 0.2;
	wait 0.01;
	element.alpha = 0.3;
	wait 0.01;
	element.alpha = 0.4;
	wait 0.01;
	element.alpha = 0.5;
	wait 0.01;
	element.alpha = 0.6;
	wait 0.01;
	element.alpha = 0.7;
	wait 0.01;
	element.alpha = 0.8;
	wait 0.01;
	element.alpha = 0.9;
	wait 0.01;
	element.alpha = 1;
}
*/